<?php
header("content-type:text/html;charset=utf-8");
include_once "../lib/databases.php";
include_once "../lib/function.php";

//接收用户注册信息
$data = isset($_POST["data"]) ? $_POST["data"] : "";

if($data == ""){
   echo $fun->success("请提交用户注册信息");
}else{
    //判断用户是否已经注册
    $res = $db->getOneData("select * from user where name = '{$data['username']}'");
    if($res != false){
        echo $fun->error("该用户已经注册");
    }else{
        //注册
        $register = $db->execSql("insert into user values(null,'{$data['username']}','".md5($data['password'])."','{$data['picture']}','{$data['email']}','{$data['phone']}')");
        if($register){
            echo $fun->success("注册成功,立即去登录");
        }else{
            echo $fun->error("注册失败，请联系管理员");
        }
    }
}
